import time


def metric(fn):

    def compute_funtime(*args, **kw):
        start_time = time.time()
        mid = fn(*args,**kw)
        end_time = time.time()
        print('耗时：{:.4f}s'.format(end_time - start_time))
        return mid
    return compute_funtime

@metric
def my_sum(n):
    time.sleep(2)
    sum = 0
    for i in range(n):
        sum = sum + i
        i +=  1
    # print('my sum is: ', sum)
    return sum

print('sum 1+2+3+....+100 is:', my_sum(101))
print()

print('sum 1+2+3+....+1000 is:', my_sum(1001))
print()

print('sum 1+2+3+....+10000 is:', my_sum(10001))
print()

print('sum 1+2+3+....+100000 is:', my_sum(100001))
